<template id="jb">
  <div>
    <el-input style="width: 25%;" v-model="jbmc" placeholder="请输入名称"></el-input>
        &nbsp;&nbsp;
        <el-button style="width: 15%;" @click="queryAll" type="primary">查询</el-button>
        <el-button style="width: 15%;" @click="kk=true"  type="primary">添加</el-button>
        <el-table :data="list">
        <el-table-column prop="id" label="编号"> 
        </el-table-column>
        <el-table-column prop="bm" label="编码" width="140">
        </el-table-column>
        <el-table-column prop="jbmc" label="疾病名称" width="120">
        </el-table-column>
        <el-table-column prop="yyisitroom.jzs" label="就诊室">
        </el-table-column>
        <el-table-column prop="yjdj" label="预警等级">
        </el-table-column>
        <el-table-column prop="jyqx" label="就医期限">
        </el-table-column>
        <el-table-column prop="sex" label="适用性别">
            <template slot-scope="scope">
                {{ scope.row.sex==0?"不限":scope.row.sex==1?"男":"女" }}
            </template>
        </el-table-column>
        <el-table-column prop="jcyy" label="常见原因">
        </el-table-column>
        <el-table-column prop="propose" label="建议">
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="primary"  icon="el-icon-edit" @click="queryId(scope.row.id),up=true"  circle></el-button>
            <el-popconfirm @confirm="del(scope.row.id)" title="这是一段内容确定删除吗">
            <el-button type="danger" slot="reference" icon="el-icon-delete" circle></el-button>
          </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[3, 5, 7, 10]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>

    <!-- 添加-->
     <el-dialog
    title="添加"
    :visible.sync="kk"
    width="30%"
    center>
    <el-form :model="jb" status-icon  ref="jb" label-width="100px" class="demo-ruleForm">
    疾病名称:<el-input v-model="jb.jbmc" style="width: 80%;"/><br>
    <h1></h1>
    适用性别:<el-select v-model="jb.sex" style="width: 80%;">
      <el-option label="不限" value="0"></el-option>
      <el-option label="男" value="1"></el-option>
      <el-option label="女" value="2"></el-option>
    </el-select><br>
    <h1></h1>
    就诊室:<el-select v-model="jb.jzksid" style="width: 80%;" placeholder="--请选择--">
      <el-option v-for="(item,index) in jz" :key="index" :label="item.jzs" :value="item.ksid"/>
    </el-select><br>
    <h1></h1>
    预警等级:<el-input v-model="jb.yjdj" style="width: 80%;"/><br>
    <h1></h1>
    就医期限:<el-input v-model="jb.jyqx" style="width: 80%;"></el-input><br>
    <h1></h1>
    常见原因:<el-input v-model="jb.jcyy" style="width: 80%;"></el-input><br>
    <h1></h1>
    建议:<el-input v-model="jb.propose" style="width: 80%;"></el-input><br>
    <h1></h1>
    <el-button @click="reset('jb'),kk = false">取 消</el-button>
    <el-button type="primary" @click="kk = false,add()" >确 定</el-button>
  </el-form>
  </el-dialog> 


  <!--修改-->
  <el-dialog
    title="修改"
    :visible.sync="up"
    width="30%"
    center>
    
    <el-form :model="jbs" status-icon  ref="jbs" label-width="100px" class="demo-ruleForm">
      <input type="hidden" v-model="jbs.id"/>
    疾病名称:<el-input v-model="jbs.jbmc" style="width: 80%;"/><br>
    <h1></h1>
    适用性别:<el-select v-model="jbs.sex" placeholder="请选择性别" style="width: 80%;">
      <el-option label="不限" value="0"></el-option> 
      <el-option label="男" value="1"></el-option>
      <el-option label="女" value="2"></el-option>
    </el-select><br>
    <h1></h1>
    就诊室:<el-select v-model="jbs.jzksid" style="width: 80%;"   >
      <el-option v-for="(item,index) in jz" :key="index" :label="item.jzs" :value="item.ksid"/>
    </el-select><br>
    <h1></h1>
    预警等级:<el-input v-model="jbs.yjdj" style="width: 80%;"/><br>
    <h1></h1>
    就医期限:<el-input v-model="jbs.jyqx" style="width: 80%;"></el-input><br>
    <h1></h1>
    常见原因:<el-input v-model="jbs.jcyy" style="width: 80%;"></el-input><br>
    <h1></h1>
    建议:<el-input v-model="jbs.propose" style="width: 80%;"></el-input><br>
    <h1></h1>
    <el-button @click="up = false">取 消</el-button>
    <el-button type="primary" @click="up = false,update()" >修改</el-button>
  </el-form>
  </el-dialog>

  </div>
</template>

<script>
export default {
    data(){
        return{
            up:false,
            jzup:[],
            jz:[],
            kk:false,
            jbmc:"",
            total:10,
            pageSize:4,
            currentPage4:1,
            list:[],
            jb:{jbmc:"",jzksid:"",yjdj:"",jyqx:"",sex:"",jcyy:"",propose:""},
            jbs:{jb:"",jbmc:"",jzksid:"",yjdj:"",jyqx:"",sex:"",jcyy:"",propose:""},
        }
    },
    methods:{
        queryAll(){
            this.axios.post("/tomcat/Z_queryJb",{page:this.currentPage4,num:this.pageSize,jbmc:this.jbmc})
            .then(s=>{
                this.total=s.data.total
                this.list=s.data.rows
            })
        },
        del(id){
          this.axios.get("/tomcat/Z_jbDel?id="+id).then(s=>{
            if(s.data>0){
              this.$notify({
                  title: '成功',
                  message: '这是一条删除成功的提示消息',
                  position: 'top-left',
                  type: 'success'
                });
                this.queryAll();
            }
          })
        },
        update(){
          this.axios.post("/tomcat/Z_jbUp",{id:this.jbs.id,jbmc:this.jbs.jbmc,jzksid:this.jbs.jzksid,
            yjdj:this.jbs.yjdj,jyqx:this.jbs.jyqx,sex:this.jbs.sex,jcyy:this.jbs.jcyy,
            propose:this.jbs.propose}).then(s=>{
              if(s.data>0){
                this.$notify({
                    title: '成功',
                    message: '这是一条修改成功的提示消息',
                    position: 'top-left',
                    type: 'success'
                  });
                  this.queryAll();
              }
            })
        },
        queryId(id){
          this.axios.post("/tomcat/Z_jbById",{id:id}).then(s=>{
             console.log(s.data)
            this.jbs=s.data
          })
        },
        add(){
          this.axios.post("/tomcat/Z_addJb",{jbmc:this.jb.jbmc,jzksid:this.jb.jzksid,
            yjdj:this.jb.yjdj,jyqx:this.jb.jyqx,sex:this.jb.sex,jcyy:this.jb.jcyy,
            propose:this.jb.propose}).then(s=>{
              if(s.data>0){
                this.$notify({
                    title: '成功',
                    message: '这是一条添加成功的提示消息',
                    position: 'top-left',
                    type: 'success'
                  });
                  this.queryAll();
                  this.reset();
              }

            })
        },
        findy(){
            this.axios.post("/tomcat/Z_findY").then(s=>{
               console.log(s.data)
                this.jz=s.data
            })
        },
        handleSizeChange(val) {
            this.pageSize=val
            this.queryAll();
            
        
        },
        handleCurrentChange(val) {
              this.currentPage4=val
              this.queryAll();
              
        },
        reset(){
              this.jb={}
        }

    },
    created(){
        this.queryAll();
        this.findy();
    }
}
</script>

<style>

</style>